import { AnyAction } from 'redux'
import { handleActions } from 'redux-actions'
import { homeUpdateState } from '@redux/action/homeActions'
import { QuestionRes } from '@service/homeService'

export interface HomeStore {
  questionList: QuestionRes[]
}

const initHomeState: HomeStore = {
  questionList: []
}

const homeReducer = handleActions({
  [homeUpdateState]: (state: HomeStore, action: AnyAction) => ({
    ...state,
    ...action.payload
  })
}, initHomeState)

export default homeReducer
